 <meta charset="utf-8">
<script src="js/jquery.js"> </script>	
<link rel="stylesheet" href="css/csstb.css" type="text/css" media="screen" />
<form action="Javascript:insertdeli();" name="deli_pop" id="deli_pop" method="post">
<?php
require("db/connect.php");
require("funcsubstr.php");
require("prename.php");
$sqlcust="select * from orders,cart,product,customer where orders.orders_id=cart.orderid and cart.pro_id=product.pro_id and customer.cus_id =orders.cus_id and  orders.orders_id=".$_GET["order"]."  ";
$querycust=mysql_query($sqlcust);
$fetch_cust=mysql_fetch_array($querycust);

$sql="select * from orders,cart,product where orders.orders_id=cart.orderid and cart.pro_id=product.pro_id and  orders.orders_id=".$_GET["order"]."";
$query=mysql_query($sql);


$sqldeli="select * from delivery where orders_id=".$_GET["order"]."";
$querydeli=mysql_query($sqldeli);
$resultdeli=mysql_fetch_array($querydeli);

 ?>
 <style>
 body {
	 
    /*background-image :url("img/pyk.jpg");
    background-repeat: no-repeat;
    background-position:top;*/
}
</style>
 <div align="center"><img src="img/pyk.JPG"  width="330" height="240" /></div>
  
 <table border="1">
	<tr>
	<td>ชื่อ-นามสกุล</td>
	<td>วันที่สั่งซื้อ</td>
    
	</tr>
    <?php
while($fetch_cust=mysql_fetch_array($querycust)){
	    $year=substr($fetch_cust["orders_date"],0,4)+543;
		$month=monthconv(substr($fetch_cust["orders_date"],5,2));
		$day=substr($fetch_cust["orders_date"],8,2);
?>
  
    <tr>
	<td><?php echo (prename($fetch_cust["cus_title"])."".$fetch_cust["cus_name"])." ".$fetch_cust["cus_lastname"]?></td>
	<td><?php echo $day.' '.$month.' '.$year?></td>
    </tr>
    </table>
    <?php
	}
?>
    
    <?php 
	if($resultdeli["delivery_addr"]!=""){
	?>
     <table border="1">
	<tr>
	<td width="20%">สถานที่จัดส่ง</td>
	<td><?php echo $resultdeli["delivery_addr"];?></td>
    
	</tr>
    </table>
    <?php
	}
	?>
    
	<table border="1">
	<tr>
	<td>รหัสสินค้า</td>
	<td>ชื่อสินค้า</td>
	<td>ราคา(หน่วย)</td>
	<td>จำนวน(แผ่น)</td>
	<td>รวม(บาท)</td>

	</tr>
	<?php 
	$countRow=0;
	$sum=0;
	while($result2=mysql_fetch_array($query)){
	$countRow++;
	$sum+=$result2["pro_price"]*$result2["qty"];
	
	 ?>
	<tr>
	<td><?php echo $result2["pro_id"];?></td>
	<td><?php echo $result2["pro_name"].color($result2["pro_color"]);?></td>
	<td style="text-align:right"><?php echo $result2["pro_price"];?></td>
	<td style="text-align:right"><?php echo $result2["qty"];?></td>
	<td style="text-align:right"><?php echo $result2["pro_price"]*$result2["qty"];?></td>

	</tr>
	 <?php }?>
	 <tr>
	 <td colspan="4" >รวมทั้งหมด(บาท)</td>
     <td  style="text-align:right"><?php echo $sum;?></td>
	 </tr>
	</table>
  
</form>